#!/usr/bin/env python
# encoding: utf-8
"""
parser.py

"""

import re
  
def parseCustomFile(sourceFile):
    """
    custom parser method to process a file and feed the IndexManager
    
    """
    r = re.compile(r'(\|.+?\||\|)\s+(\|.+?\|)\s+(.+)\s+([A-Z]+)\s+(.+)', re.UNICODE)
    LINECOUNT = 0
    for x in open(sourceFile):
        #LINECOUNT = LINECOUNT + 1       # here the actual file line number gets counted
        p = r.search(x)
        if p:
            LINECOUNT = LINECOUNT + 1   # here a relativ number gets counted
            yield (p, LINECOUNT)	    # use yield here: generator
        else:
            pass
            #print 'no match...'
    return

